package com.sure.supermarketserver.sell.adjust;

import com.sure.supermarketserver.common.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/cargo/manage")
public class CargoAPI {
    @Resource
    private CargoService cargoService;

    @GetMapping("/page")
    public Result cargoPage(CargoDto dto){
        Map<String, Object> goodsPage = new HashMap<>();
        try {
            goodsPage = cargoService.cargoPage(dto);
        }catch (Exception e) {
            return Result.fail(Result.ERR_CODE_BUSINESS, e.getMessage());
        }
        return Result.success(goodsPage);
    }

    @PutMapping("")
    public Result cargoUpd(@RequestBody CargoDto dto) {
        try {
            cargoService.updCargo(dto);
        }catch (Exception e) {
            return Result.fail(Result.ERR_CODE_BUSINESS, e.getMessage());
        }
        return Result.success();
    }
}
